<script setup>
// 获取 route 路由
import {useRoute} from "vue-router";
import {onMounted} from "vue";

const route = useRoute();

onMounted(() => {
  console.log('路由名称：', route.name)
  console.log('路由路径：', route.path)
  console.log('元数据：', route.meta)
  console.log('传递参数：', route.params)
  console.log('传递参数：', route.query)
  console.log('完整路径：', route.fullPath)
  console.log('路由匹配：', route.matched)
  console.log('hash值：', route.hash)
  console.log('重定向：', route.redirectedFrom)
});
</script>

<template>
  <div>
    Page A. <br>
    <router-link to="/b/page">返回PageB</router-link>
    <br>
    <router-link to="/a/page/a1">A1</router-link>
    &nbsp;&nbsp;
    <router-link :to="{name:'A2_Page',query:{id:1,name:'测试参数'}}">A2</router-link>
    <!--  这里使用 router-view 显示子路由组件内容  -->
    <router-view/>
  </div>
</template>

<style scoped>
div {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  margin-top: 60px;
  background-color: #fafafa;
  font-size: 20px;
}
</style>